const {
	Service
} = require('uni-cloud-router')

module.exports = class WxPubUserService extends Service {
	async getWxPubUser({
		city,
		unionId
	}) {
		try {
			let res = await this.db.collection('t3ds-wx-pub-user').where({
					city,
					unionId
				})
				.field({
					openId: true,
					unionId: true,
					createTime: true
				})
				.limit(1)
				.get()
			if (res.data.length) {
				return res.data[0]
			}
		} catch (e) {
			throw e
		}
	}
}
